import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)


// 公共路由
export const constantRoutes = [
    {
        path: '/',
        name: 'index',
        component: () => import('@/views/Home/index.vue'),
    }, {
        path: '/video',
        name: 'video',
        component: () => import('@/views/Video/index.vue'),
    },{
        path: '/play',
        name: 'play',
        component: () => import('@/views/Video/play.vue'),
    },{
        path: '/picture',
        name: 'picture',
        component: () => import('@/views/Picture/index.vue'),
    },{
        path: '/picture/content',
        name: 'picture/content',
        component: () => import('@/views/Picture/content.vue'),
    },{
        path: '/novel',
        name: 'novel',
        component: () => import('@/views/Novel/index.vue'),
    },{
        path: '/novel/content',
        name: 'novel/content',
        component: () => import('@/views/Novel/content.vue'),
    },{
        path: '/ranking',
        name: 'ranking',
        component: () => import('@/views/Ranking/index'),
    },{
        path: '/ranking/more',
        name: 'more',
        component: () => import('@/views/Ranking/more'),
    }, {
        path: '/help',
        component: () => import('@/views/Help/index.vue'),
        redirect: '/help/menu',
        children: [
            {
                path: 'menu',
                name: 'menu',
                component: () => import('@/views/Help/pages/menu'),
            },
            {
                path: 'notice',
                name: 'notice',
                component: () => import('@/views/Help/pages/Notice'),
            },
        ]
    }



]

// 防止连续点击多次路由报错
let routerPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(err => err)
}

export default new Router({
    mode: 'hash', // hash 去掉url中的#  history
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})
